package com.dbky.alg.core.social.qq.connect;

import com.dbky.alg.core.social.qq.api.QQ;
import com.dbky.alg.core.social.qq.api.QQImpl;
import org.springframework.social.oauth2.AbstractOAuth2ServiceProvider;
import org.springframework.social.oauth2.OAuth2Operations;
import org.springframework.social.oauth2.OAuth2Template;

/**
 * @Auther: tianchao
 * @Date: 2021/12/14 20:59
 * @Description:
 */
public class QQServiceProvider extends AbstractOAuth2ServiceProvider<QQ> {

    private String appId;

    private static final String URL_authorize = "https://graph.qq.com/oauth2.0/authorize";

    private static final String URL_accessToken = "https://graph.qq.com/oauth2.0/token";
    /**
     * Create a new {@link OAuth2ServiceProvider}.
     *
     * @param oauth2Operations the OAuth2Operations template for conducting the OAuth 2 flow with the provider.
     */
    public QQServiceProvider(String appId,String appSecret) {
        //super(oauth2Operations);
        super(new OAuth2Template(appId, appSecret, URL_authorize, URL_accessToken));
    }

    @Override
    public QQ getApi(String accessToken) {
        return new QQImpl(accessToken, appId);
    }
}
